/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package generadorva;

import ec.util.MersenneTwisterFast;

/**
 *
 * @author USUARIO
 */
public class Beta34 {
    
    private int ciclos;

    public double generar(MersenneTwisterFast prng){
        ciclos = 1;
        double u = prng.nextDouble();
        double x = prng.nextDouble();
        double a = 1296.0/625.0;
        while (u > 60*(1-x)*(1-x)*(1-x)*x*x/a) {
            ciclos++;
            u = prng.nextDouble();
            x = prng.nextDouble();
        }
        return x;
    }

    public int getCiclos() {
        return ciclos;
    }
    
    public static void main(String[] args) {
        Beta34 beta34 = new Beta34();
        MersenneTwisterFast mersenneTwisterFast = new MersenneTwisterFast(7323517);
        int n = 10000;
        double sumaciclos = 0.0;
        for (int i = 0; i < n; i++) {
            double x = beta34.generar(mersenneTwisterFast);
            sumaciclos += beta34.getCiclos();
        }
        double mediaCiclos = sumaciclos / (n*1.0);
        System.out.println("media cilcos: " + mediaCiclos);
    }
}
